{layout name="layout2" /}
<script src="__PUBLIC__/static/common/js/area.js"></script>
<div class="layui-form" lay-filter="layuiadmin-form-unit" id="layuiadmin-form-unit" style="padding: 20px 30px 0 0;">
 <div class="layui-form-item">
        <label class="layui-form-label" style="white-space: nowrap;"><font color="red">*</font>基地名称：</label>
        <div class="layui-input-inline" style="width: 400px">
            <input type="text" name="name" value = '{$info.name}' lay-verify="required" lay-vertype="tips" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
      <div class="layui-form-item">
        <label class="layui-form-label" style="white-space: nowrap;"><font color="red">*</font>基地简介：</label>
        <div class="layui-input-inline" style="width: 400px">
            <input type="text" name="remark" value = '{$info.remark}' lay-verify="required" lay-vertype="tips" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
      <div class="layui-form-item">
        <label class="layui-form-label" style="white-space: nowrap;"><font color="red">*</font>基地地址：</label>
        <div class="layui-input-inline" style="width: 400px">
            <input type="text" name="address" value = '{$info.address}' lay-verify="required" lay-vertype="tips" placeholder="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <input type="hidden" name="id" value="{$info.id}"  lay-vertype="tips" placeholder="" autocomplete="off" class="layui-input">
   <div class="layui-form-item">
        <label class="layui-form-label">基地图片：</label>
        <div class="layui-input-block">
            <div class="img-content">
                <input name="img" type="hidden" value="{$info.img}">
                <div class="img-add"  {if $info.img } style="display: none" {/if} ></div>
            {if !empty($info.img)}
            <div class="img-container">
                <img class="img-src" src="{$info.img}">
                <a class="img-del-x">x</a>
            </div>
            {/if}
        </div>
        </div>
    </div>
 <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-inline">
            

            <select name="role_id" id = 'aa' xm-select="welfare" xm-select-search="" xm-select-search-type="dl" xm-select-skin="normal" >
                {volist name="role_lists" id="vo"}
                                           
                  <option value="{$vo.id}">{$vo.name}</option>                                                                                  
                {/volist} 
              
            </select>
           
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="Basis-submit" id="Basis-submit" value="确认">
    </div>
</div>
<link rel="stylesheet" href="/static/plug/formSelects/formSelects-v4.css" />
<script src="/static/plug/formSelects/formSelects-v4.js" type="text/javascript" charset="utf-8"></script>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script>
      var value ={:json_encode($info.role_id)};
      if(value!=''){
        for (let a of value) {
         $('#aa').find("option[value="+a+"]").attr("selected",true);
        }
      }
      
    layui.config({
        version:"{$front_version}",
        base: '/static/plug/layui-admin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form','laydate','like'], function(){
            var $ = layui.$
            ,form = layui.form
            ,laydate = layui.laydate
            ,like = layui.like;
        laydate.render({
            elem: '#birthday'
            ,format: 'yyyy-MM-dd'
            ,trigger: 'click'
        });
        like.imageUpload('.img-add', function (uris, element) {
            if(uris.length>1){
                layer.msg('最多最能选中1张图片');
                return;
            }
            var html = '<div class="img-container">\n' +
                '<img class="img-src" ' +
                'src="'  + uris[0] + '">' +
                '<a class="img-del-x">x</a>' +
                '</div>';
            element.prev().val('/'+uris[0]);
            element.parent().append(html);
            element.css('display','none');
        }, true);
        //删除图片
        $(document).on('click', '.img-del-x', function () {
            $(this).parent().siblings('input').val('');
            $(this).parent().prev().css('display','block');
            $(this).parent().remove();
        });
        //显示图片
        $(document).on('click', '.img-src', function () {
            var image = $(this).attr('src');
            like.showImg(image,600);
        });

        form.on('select(category)', function(data){
            var level = $(data.elem).find("option:selected").attr("data-level");
            $('.alliance_ratio').hide();
            $('.autotrophy_ratio').hide();
            if(level == 2){
                $('.alliance_ratio').show();
                $('.autotrophy_ratio').show();

            }
        });


    })
</script>